const state = {
    currentMenu: {},
    tabsList: [
        {
            path: '/',
            name: 'home',
            label: '首页',
            icon: 'home'
        }
    ]
}
const actions = {

}
const mutations = {
    //选择标签 选择面包屑
    selectMenu(state, val) {
        if (val.name === 'home') {
            state.currentMenu = {}
        } else {
            console.log('val=',val)
            console.log('state.tabsList=', state.tabsList)
            state.currentMenu.path = val.menu_url
            state.currentMenu.label = val.menu_name
            console.log('state.currentMenu=', state.currentMenu)
            //如果等于-1说明tabsList不存在那么插入，否则什么都不做
            let result = state.tabsList.findIndex(item => item.label === val.menu_name)
            result === -1 ? state.tabsList.push(val) : ''

        }
        // val.name === 'home' ? (state.currentMenu = null) : (state.currentMenu = val)
    },
     //关闭标签
     closeTab(state, val) {
        let result = state.tabsList.findIndex(item => item.name === val.name)
        state.tabsList.splice(result, 1)
    },
}
const getters = {}
export default{
    state,
    actions,
    mutations,
    getters
}